﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using Xss.Message;
using Xss.Data.Sql;

namespace Xss.Data.Mapper
{

    /// <summary>
    /// 数据映射
    /// </summary>
    public interface IAdoMapper : IDisposable
    {
        // <summary>
        /// 预执行事件
        /// </summary>
        event EventHandler<EventArgs> PreExecute;
        // <summary>
        /// 执行后事件
        /// </summary>
        event EventHandler<EventArgs> PoseExecute;


        /// <summary>
        /// 上级映射
        /// </summary>
        IAdoMapper Parent { get; set; }

        /// <summary>
        /// 下级映射
        /// </summary>
        IAdoMapper Next { get; set; }

        /// <summary>
        /// 映射编号
        /// </summary>
        ISqlProvider Sql { get; set; }

        /// <summary>
        /// 映射类型
        /// </summary>
        Type MapperType { get; set; }

        object Paramater { get; set; }

        /// <summary>
        /// 验证解析参数，是否继续向下执行
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        bool ParseParamater(object result);

        /// <summary>
        /// 验证失败时是否回滚
        /// </summary>
        bool IsValidRollback { get; set; }

        /// <summary>
        /// 执行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        object Execute();

        /// <summary>
        /// 消息上下文
        /// </summary>
        MessageContext Message { get; set; }

        /// <summary>
        /// 数据会话
        /// </summary>
        IAdoRequest Request { get; set; }
    }
}
